package com.freestyle.nettychat.chat.dto;

import com.freestyle.nettychat.chat.CodeConsts;

/**
 * Created by rocklee on 2022/2/4 21:25
 */
public class TextMessage extends ChatMessage<String> {
  public static TextMessage fromText(long id,String chatRoom,String uuid,String text){
    ChatMessageProperties properties=new ChatMessageProperties();
    properties.setChatRoom(chatRoom);
    properties.setId(id);
    properties.setUuid(uuid);
    properties.setSClass(CodeConsts.MessageType.text.toString());
    TextMessage message=new TextMessage();
    message.setProperties(properties);
    message.setData(text);
    return message;
  }
  public static TextMessage fromMessage(ChatMessage message){
    TextMessage textMessage=new TextMessage();
    textMessage.setProperties(message.getProperties());
    textMessage.getProperties().setSClass(CodeConsts.MessageType.text.toString());
    textMessage.setData((String) message.getData());
    return textMessage;
  }
}
